<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content=
    "application/xhtml+xml; charset=iso-8859-1" />
    <title>
      8.3.&nbsp;Linux-3.8.1
    </title>
    <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
    "text/css" media="print" />
  </head>
  <body class="lfs" id="lfs-7.3">
    <div class="navheader">
      <h4>
        Linux From Scratch - Version 7.3
      </h4>
      <h3>
        Chapter&nbsp;8.&nbsp;Making the LFS System Bootable
      </h3>
      <ul>
        <li class="prev">
          <a accesskey="p" href="fstab.html" title=
          "Creating the /etc/fstab File">Prev</a>
          <p>
            Creating the /etc/fstab File
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="grub.html" title=
          "Using GRUB to Set Up the Boot Process">Next</a>
          <p>
            Using GRUB to Set Up the Boot Process
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="chapter08.html" title=
          "Chapter&nbsp;8.&nbsp;Making the LFS System Bootable">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Linux From Scratch - Version 7.3">Home</a>
        </li>
      </ul>
    </div>
    <div class="wrap" lang="en" xml:lang="en">
      <h1 class="sect1">
        <a id="ch-bootable-kernel" name="ch-bootable-kernel"></a>8.3.
        Linux-3.8.1
      </h1>
      <div class="package" lang="en" xml:lang="en">
        <p>
          The Linux package contains the Linux kernel.
        </p>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong class="segtitle">Approximate build time:</strong>
              <span class="segbody">1.0 - 5.0 SBU</span>
            </div>
            <div class="seg">
              <strong class="segtitle">Required disk space:</strong>
              <span class="segbody">540 - 800 MB</span>
            </div>
          </div>
        </div>
      </div>
      <div class="installation" lang="en" xml:lang="en">
        <h2 class="sect2">
          8.3.1. Installation of the kernel
        </h2>
        <p>
          Building the kernel involves a few steps&mdash;configuration,
          compilation, and installation. Read the <code class=
          "filename">README</code> file in the kernel source tree for
          alternative methods to the way this book configures the kernel.
        </p>
        <p>
          Prepare for compilation by running the following command:
        </p>
        <pre class="userinput">
<kbd class="command">make mrproper</kbd>
</pre>
        <p>
          This ensures that the kernel tree is absolutely clean. The kernel
          team recommends that this command be issued prior to each kernel
          compilation. Do not rely on the source tree being clean after
          un-tarring.
        </p>
        <p>
          Configure the kernel via a menu-driven interface. For general
          information on kernel configuration see <a class="ulink" href=
          "http://www.linuxfromscratch.org/hints/downloads/files/kernel-configuration.txt">
          http://www.linuxfromscratch.org/hints/downloads/files/kernel-configuration.txt</a>.
          BLFS has some information regarding particular kernel configuration
          requirements of packages outside of LFS at <a class="ulink" href=
          "http://www.linuxfromscratch.org/blfs/view/svn/longindex.html#kernel-config-index">
          http://www.linuxfromscratch.org/blfs/view/svn/longindex.html#kernel-config-index</a>.
        </p>
        <div class="admon note">
          <img alt="[Note]" src="../images/note.png" />
          <h3>
            Note
          </h3>
          <p>
            Due to recent changes in <span class="application">udev</span>,
            be sure to select:
          </p>
          <pre class="screen">
Device Drivers  ---&gt;
  Generic Driver Options  ---&gt;
     Maintain a devtmpfs filesystem to mount at /dev
</pre>
        </div>
        <pre class="userinput">
<kbd class="command">make LANG=<em class=
"replaceable"><code>&lt;host_LANG_value&gt;</code></em> LC_ALL= menuconfig</kbd>
</pre>
        <div class="variablelist">
          <p class="title">
            <b>The meaning of the make parameters:</b>
          </p>
          <dl>
            <dt>
              <span class="term"><em class=
              "parameter"><code>LANG=&lt;host_LANG_value&gt;
              LC_ALL=</code></em></span>
            </dt>
            <dd>
              <p>
                This establishes the locale setting to the one used on the
                host. This is needed for a proper menuconfig ncurses
                interface line drawing on UTF-8 linux text console.
              </p>
              <p>
                Be sure to replace <em class=
                "replaceable"><code>&lt;host_LANG_value&gt;</code></em> by
                the value of the <code class="envar">$LANG</code> variable
                from your host. If not set, you could use instead the host's
                value of <code class="envar">$LC_ALL</code> or <code class=
                "envar">$LC_CTYPE</code>.
              </p>
            </dd>
          </dl>
        </div>
        <p>
          Alternatively, <span class="command"><strong>make
          oldconfig</strong></span> may be more appropriate in some
          situations. See the <code class="filename">README</code> file for
          more information.
        </p>
        <p>
          If desired, skip kernel configuration by copying the kernel config
          file, <code class="filename">.config</code>, from the host system
          (assuming it is available) to the unpacked <code class=
          "filename">linux-3.8.1</code> directory. However, we do not
          recommend this option. It is often better to explore all the
          configuration menus and create the kernel configuration from
          scratch.
        </p>
        <p>
          Compile the kernel image and modules:
        </p>
        <pre class="userinput">
<kbd class="command">make</kbd>
</pre>
        <p>
          If using kernel modules, module configuration in <code class=
          "filename">/etc/modprobe.d</code> may be required. Information
          pertaining to modules and kernel configuration is located in
          <a class="xref" href="../chapter07/udev.html" title=
          "7.4.&nbsp;Device and Module Handling on an LFS System">Section&nbsp;7.4,
          &ldquo;Device and Module Handling on an LFS System&rdquo;</a> and
          in the kernel documentation in the <code class=
          "filename">linux-3.8.1/Documentation</code> directory. Also,
          <code class="filename">modprobe.conf(5)</code> may be of interest.
        </p>
        <p>
          Install the modules, if the kernel configuration uses them:
        </p>
        <pre class="userinput">
<kbd class="command">make modules_install</kbd>
</pre>
        <p>
          After kernel compilation is complete, additional steps are required
          to complete the installation. Some files need to be copied to the
          <code class="filename">/boot</code> directory.
        </p>
        <p>
          The path to the kernel image may vary depending on the platform
          being used. The filename below can be changed to suit your taste,
          but the stem of the filename should be <span class=
          "emphasis"><em>vmlinuz</em></span> to be compatible with the
          automatic setup of the boot process described in the next section.
          The following command assumes an x86 architecture:
        </p>
        <pre class="userinput">
<kbd class=
"command">cp -v arch/x86/boot/bzImage /boot/vmlinuz-3.8.1-lfs-7.3</kbd>
</pre>
        <p>
          <code class="filename">System.map</code> is a symbol file for the
          kernel. It maps the function entry points of every function in the
          kernel API, as well as the addresses of the kernel data structures
          for the running kernel. It is used as a resource when investigating
          kernel problems. Issue the following command to install the map
          file:
        </p>
        <pre class="userinput">
<kbd class="command">cp -v System.map /boot/System.map-3.8.1</kbd>
</pre>
        <p>
          The kernel configuration file <code class="filename">.config</code>
          produced by the <span class="command"><strong>make
          menuconfig</strong></span> step above contains all the
          configuration selections for the kernel that was just compiled. It
          is a good idea to keep this file for future reference:
        </p>
        <pre class="userinput">
<kbd class="command">cp -v .config /boot/config-3.8.1</kbd>
</pre>
        <p>
          Install the documentation for the Linux kernel:
        </p>
        <pre class="userinput">
<kbd class="command">install -d /usr/share/doc/linux-3.8.1
cp -r Documentation/* /usr/share/doc/linux-3.8.1</kbd>
</pre>
        <p>
          It is important to note that the files in the kernel source
          directory are not owned by <span class=
          "emphasis"><em>root</em></span>. Whenever a package is unpacked as
          user <span class="emphasis"><em>root</em></span> (like we did
          inside chroot), the files have the user and group IDs of whatever
          they were on the packager's computer. This is usually not a problem
          for any other package to be installed because the source tree is
          removed after the installation. However, the Linux source tree is
          often retained for a long time. Because of this, there is a chance
          that whatever user ID the packager used will be assigned to
          somebody on the machine. That person would then have write access
          to the kernel source.
        </p>
        <p>
          If the kernel source tree is going to be retained, run <span class=
          "command"><strong>chown -R 0:0</strong></span> on the <code class=
          "filename">linux-3.8.1</code> directory to ensure all files are
          owned by user <span class="emphasis"><em>root</em></span>.
        </p>
        <div class="admon warning">
          <img alt="[Warning]" src="../images/warning.png" />
          <h3>
            Warning
          </h3>
          <p>
            Some kernel documentation recommends creating a symlink from
            <code class="filename">/usr/src/linux</code> pointing to the
            kernel source directory. This is specific to kernels prior to the
            2.6 series and <span class="emphasis"><em>must not</em></span> be
            created on an LFS system as it can cause problems for packages
            you may wish to build once your base LFS system is complete.
          </p>
        </div>
        <div class="admon warning">
          <img alt="[Warning]" src="../images/warning.png" />
          <h3>
            Warning
          </h3>
          <p>
            The headers in the system's <code class="filename">include</code>
            directory should <span class="emphasis"><em>always</em></span> be
            the ones against which Glibc was compiled, that is, the sanitised
            headers from this Linux kernel tarball. Therefore, they should
            <span class="emphasis"><em>never</em></span> be replaced by
            either the raw kernel headers or any other kernel sanitized
            headers.
          </p>
        </div>
      </div>
      <div class="configuration" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="conf-modprobe" name="conf-modprobe"></a>8.3.2. Configuring
          Linux Module Load Order
        </h2>
        <p>
          Most of the time Linux modules are loaded automatically, but
          sometimes it needs some specific direction. The program that loads
          modules, <span class="command"><strong>modprobe</strong></span> or
          <span class="command"><strong>insmod</strong></span>, uses
          <code class="filename">/etc/modprobe.d/usb.conf</code> for this
          purpose. This file needs to be created so that if the USB drivers
          (ehci_hcd, ohci_hcd and uhci_hcd) have been built as modules, they
          will be loaded in the correct order; ehci_hcd needs to be loaded
          prior to ohci_hcd and uhci_hcd in order to avoid a warning being
          output at boot time.
        </p>
        <p>
          Create a new file <code class=
          "filename">/etc/modprobe.d/usb.conf</code> by running the
          following:
        </p>
        <pre class="userinput">
<kbd class="command">install -v -m755 -d /etc/modprobe.d
cat &gt; /etc/modprobe.d/usb.conf &lt;&lt; "EOF"
<code class="literal"># Begin /etc/modprobe.d/usb.conf

install ohci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i ohci_hcd ; true
install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true

# End /etc/modprobe.d/usb.conf</code>
EOF</kbd>
</pre>
      </div>
      <div class="content" lang="en" xml:lang="en">
        <h2 class="sect2">
          <a id="contents-kernel" name="contents-kernel"></a>8.3.3. Contents
          of Linux
        </h2>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong class="segtitle">Installed files:</strong> <span class=
              "segbody">config-3.8.1, vmlinux-3.8.1-lfs-7.3-3.8.1, and
              System.map-3.8.1</span>
            </div>
            <div class="seg">
              <strong class="segtitle">Installed directories:</strong>
              <span class="segbody">/lib/modules,
              /usr/share/doc/linux-3.8.1</span>
            </div>
          </div>
        </div>
        <div class="variablelist">
          <h3>
            Short Descriptions
          </h3>
          <table border="0">
            <col align="left" valign="top" />
            <tbody>
              <tr>
                <td>
                  <p>
                    <a id="config" name="config"></a><span class=
                    "term"><code class="filename">config-3.8.1</code></span>
                  </p>
                </td>
                <td>
                  <p>
                    Contains all the configuration selections for the kernel
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="lfskernel" name="lfskernel"></a><span class=
                    "term"><code class=
                    "filename">vmlinux-3.8.1-lfs-7.3</code></span>
                  </p>
                </td>
                <td>
                  <p>
                    The engine of the Linux system. When turning on the
                    computer, the kernel is the first part of the operating
                    system that gets loaded. It detects and initializes all
                    components of the computer's hardware, then makes these
                    components available as a tree of files to the software
                    and turns a single CPU into a multitasking machine
                    capable of running scores of programs seemingly at the
                    same time
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="System.map" name="System.map"></a><span class=
                    "term"><code class=
                    "filename">System.map-3.8.1</code></span>
                  </p>
                </td>
                <td>
                  <p>
                    A list of addresses and symbols; it maps the entry points
                    and addresses of all the functions and data structures in
                    the kernel
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="fstab.html" title=
          "Creating the /etc/fstab File">Prev</a>
          <p>
            Creating the /etc/fstab File
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="grub.html" title=
          "Using GRUB to Set Up the Boot Process">Next</a>
          <p>
            Using GRUB to Set Up the Boot Process
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="chapter08.html" title=
          "Chapter&nbsp;8.&nbsp;Making the LFS System Bootable">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Linux From Scratch - Version 7.3">Home</a>
        </li>
      </ul>
    </div>
  </body>
</html>
